//=============================================================================
//D <One line description>
//
// <Details of class and its usage from code/internal viewpoint>
//
// ----------------------------------------------------------------------------
// Copyright 2013 Delcam plc., Birmingham, UK
// ----------------------------------------------------------------------------
//
// History.
// DICC   Who When     What   
// ------ --- -------- --------------------------------------------------------
// 999999 CLH 18/09/13 Written.
//-----------------------------------------------------------------------------
#include "stdafx.h"

#include "cpp/cppSFINAE.h"

// additional includes from 'cpp' library
// includes from PowerINSPECT libraries
// includes from Delcam libraries
#include "utils/ut_assert.h"   // Use assertions!
// includes from other libraries
// system includes
#include <iostream>
// types: classes, enums, typedefs

// variables: consts, statics, exported variables (declared extern elsewhere)
// local forward function declarations

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

class SFINAE1 {
public:
  typedef int type_one;
  void print() { std::cout << "one\n"; }
};

class SFINAE2 {
public:
  typedef double type_two;
  void p() { std::cout << "one\n"; }
};


template <class T>
typename T::type_one print(T t)
{
  std::cout << "type_one" << std::endl;
  t.print();

  return 1;
}

template <class T>
typename T::type_two print(T t)
{
  std::cout << "type_two" << std::endl;
  t.p();

  return 2.3;
}

//=============================================================================
cppSFINAE::cppSFINAE()
//
//D Default constructor.
//
// History.
// DICC   Who When     What   
// ------ --- -------- --------------------------------------------------------
// 999999 CLH 18/09/13 Written.
//-----------------------------------------------------------------------------
{
  UT_CHECKVALID_CLASS;
}

//=============================================================================
cppSFINAE::~cppSFINAE()
//
//D Destructor.
//
// History.
// DICC   Who When     What   
// ------ --- -------- --------------------------------------------------------
// 999999 CLH 18/09/13 Written.
//-----------------------------------------------------------------------------
{
  UT_CHECKVALID_CLASS;
}

//=============================================================================
void cppSFINAE::run()
//
//D Runs the example
//
// History.
// DICC   Who When     What   
// ------ --- -------- --------------------------------------------------------
// 999999 CLH 18/09/13 Written.
//-----------------------------------------------------------------------------
{
  UT_CHECKVALID_CLASS;
  UT_ASSERT(true, "Assert preconditions");

  SFINAE1 one;
  print(one);

  SFINAE2 two;
  print(two);

}
